/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.click.app.dao.hibernate;

import com.click.app.dao.PeriodPaymentEmployeeDao;
import com.click.app.model.PeriodPaymentEmployee;
import java.util.List;

/**
 *
 * @author ronald
 */
public class PeriodPaymentEmployeeDaoHibernate extends GenericDaoHibernate<PeriodPaymentEmployee, Long>
        implements PeriodPaymentEmployeeDao {

    public PeriodPaymentEmployeeDaoHibernate() {
        super(PeriodPaymentEmployee.class);
    }

    public PeriodPaymentEmployee getCurrentPeriodByIdEmployeeAndRole(Long idEmployee, Long idRole) {
        PeriodPaymentEmployee periodPaymentEmployee;
        Object ids[] = {idEmployee, idRole};
        List<PeriodPaymentEmployee> listPerPayEmp = getHibernateTemplate().find("from PeriodPaymentEmployee where employee.id=? AND role.id=? AND closed = false ", ids);
        if (!listPerPayEmp.isEmpty()) {
            periodPaymentEmployee = listPerPayEmp.get(0);
        } else {
            periodPaymentEmployee = new PeriodPaymentEmployee();
        }

        return periodPaymentEmployee;
    }
}